package com.house.business.controller;

import lombok.extern.slf4j.Slf4j;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.house.business.service.ReservationService;
import com.house.business.entity.Reservation;
import com.house.business.vo.ReservationVo;
import org.springframework.web.bind.annotation.RestController;
import com.house.framework.controller.BaseController;

/**
 * <p>
 * 预约看房表 前端控制器
 * </p>
 *
 * @since 2023-05-09
 */
@Slf4j
@RestController
@RequestMapping("/reservationController")
public class ReservationController extends BaseController {

    @Autowired
    private ReservationService reservationService;
    /**
    * 新增预约看房表
    * @param entity
    * t_reservation新增数据
    * @return 新增数据id
    */
    @ApiOperation(value = "预约看房表", notes = "新增预约看房表")
    @RequestMapping(value = "/addReservation", method = RequestMethod.POST)
    public Object addReservation(@RequestBody Reservation entity) {
        return reservationService.addReservation(entity);
    }

    /**
    * 修改预约看房表
    * @param entity
    * t_reservation修改数据
    * @return 修改记录数
    */
    @ApiOperation(value = "预约看房表", notes = "修改预约看房表")
    @RequestMapping(value = "/updateReservation", method = RequestMethod.POST)
    public Object updateReservation(@RequestBody Reservation entity) {
        return reservationService.updateReservation(entity);
    }

    /**
    * 取指定ID的预约看房表数据
    * @param id
    * t_reservation 主键ID
    * @return 返回实体对象
    * 返回指定id 预约看房表数据
    */
    @ApiOperation(value = "预约看房表", notes = "取预约看房表")
    @RequestMapping(value = "/getReservationById", method = RequestMethod.GET)
    public ReservationVo getReservationById(@RequestParam Long id) {
        return reservationService.getReservationById(id);
    }

    /**
    * 预约看房表分页取数
    * @param entityVo
    * t_reservation 分页取数参数，pageIndex=页码；pageSize=每页记录数；
    * @return
    * 返回分页数据
    */
    @RequestMapping(value = "/getReservationList", method = RequestMethod.POST)
    public IPage<ReservationVo> getReservationList(@RequestBody ReservationVo entityVo){
        IPage<ReservationVo> page = reservationService.getReservationList(entityVo);
        return page;
    }

    /**
    * 删除指定ID的预约看房表数据
    * @param id
    * t_reservation 主键ID
    */
    @ApiOperation(value = "预约看房表", notes = "删除预约看房表")
    @RequestMapping(value = "/deleteReservationById/{id}", method = RequestMethod.GET)
    public void deleteReservationById(@PathVariable("id") Long id) {
         reservationService.deleteReservationById(id);
    }

    /**
    * 批量删除指定ID的预约看房表数据
    * @param ids
    * t_reservation 主键ID
    */
    @ApiOperation(value = "预约看房表", notes = "批量删除预约看房表")
    @RequestMapping(value = "/batchDelete", method = RequestMethod.POST)
    public void batchDelete(@RequestParam Long[] ids) {
        reservationService.batchDelete(ids);
    }

}
